<?php

/* Copyright 2007 
Author: Albert Lash
License: LGPL
*/

if(!is_writable(".") || !is_writable("../build/")) { 
    echo "ERROR: <font color='red'>The build and htdocs folders must be writable by the webserver to continue.";
    echo "<br/>Sorry, I'm giving up!</font>";
    echo "<br/>If you are on debian, you might be able to use these commands to fix this problem: 
    <pre>chown -R www-data htdocs</pre>
    <pre>chown -R www-data build</pre>
    ";
    die;
}

// Want to manually specify the vhost path?
$vhost_path ="";
if(empty($vhost_path)) { 
	$vhost_path = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
}

// Where is Nexista directory located?
define(INCLUDE_PATH, "/usr/share/php/");
$server_name = $_SERVER['SERVER_NAME'];
$config_file = $vhost_path.'/conf/config.xml';
$build_type="dev";

$domain_name = $_SERVER['SERVER_NAME'];
define(DOMAIN_NAME,str_replace("www.","",$domain_name));

define(DOCUMENT_ROOT,$vhost_path);

require(INCLUDE_PATH.'nexista/kernel/foundry.php');
Error::addObserver('display', 'observerDisplay');

$foundry = Foundry::singleton();


$foundry->configure($config_file,NULL, $build_type);
$foundry->debug = 1;


echo "Building index file....OK<br/>";


$foundry->buildLoader();
$foundry->buildGates();  
$foundry->buildSitemap();

function observerDisplay($e)
{
   $e->toText();  
}



?>
